import { createRouter, createWebHashHistory } from 'vue-router'
import routes from 'virtual:generated-pages'
console.log(routes, '打印生成自动生成的路由')

routes.push(
  {
    path: '/',
    name: 'index',
    redirect: '/homepage',
    //component: () => import('/@/pages/homePage/index.vue'),
    component: () => import('/@/pages/index.vue'),
    children:[
      {
        path : '/homepage',
        name : 'homePage',
        component: () => import('/@/pages/homePage/index.vue'), // 学生首页
        meta:{name:'homePage'},
      },
      {
        path :"/course",
        name :'course',
        component: () => import('/@/pages/course/index.vue'), // 课程列表
        meta:{name:'course'},
      },
      {
        path : "/course/coursedetail",
        name : "course-courseDetail",
        component: () => import('/@/pages/course/courseDetail.vue'), // 课程详情
        meta:{name:'courseDetail'},
      },
      {
        path :"/vip",
        name :'vip',
        component: () => import('/@/pages/vip/index.vue'), // 课程列表
        meta:{name:'vip'},
      },
      {
        path :"/teacher",
        name :'teacher',
        component: () => import('/@/pages/teacher/index.vue'), // 教师列表
        meta:{name:'teacher'},
      },
      {
        path :"/teacher/teacherdetail",
        name :'teacher-teacherDetail',
        component: () => import('/@/pages/teacher/teacherDetail.vue'), // 教师详情
        meta:{name:'teacher'},
      },
      {
        path :"/qa",
        name :'qa',
        component: () => import('/@/pages/qa/index.vue'), // 答疑列表
        meta:{name:'qa'},
      },
      {
        path :"/activity",
        name :'activity',
        component: () => import('/@/pages/activity/index.vue'), // 活动列表
        meta:{name:'activity'},
      },
      {
        path :"/activity/activitydetail", // vite 自动生成的path 和 name 
        name :'activity-activityDetail',
        component: () => import('/@/pages/activity/activityDetail.vue'), // 活动详情
        meta:{name:'activity-activityDetail'},
      },
      {
        path :"/newslist",
        name :'newsList',
        component: () => import('/@/pages/news/newsList.vue'), // 新闻列表
        meta:{name:'newsList'},
      },
      {
        path :"/newsdetail",
        name :'newsDetail',
        component: () => import('/@/pages/news/newsDetail.vue'), // 新闻详情
        meta:{name:'newsDetail'},
      },
      {
        path :"/order/orderpay",
        name :'order-orderPay',
        component: () => import('/@/pages/order/orderPay.vue'), // 购物车列表页
        // meta:{name:'orderPay'},
      },
      {
        path :"/order/checkorder",
        name :'order-checkOrder',
        component: () => import('/@/pages/order/checkOrder.vue'), // 购物车确认页
        // meta:{name:'orderPay'},
      },
      {
        path:'/usercenter',
        name:'userCenter',
        redirect: '/usercenter/usercenter',
        component: () =>import('/@/pages/userCenter/index.vue'), // 学生首页
        children:[
          {
            path : '/usercenter/usercenter',
            name : 'userCenter-userCenter',
            component: () => import('/@/pages/userCenter/userCenter.vue'), // 学生首页
            //meta:{name:'userCenter'},
          },
          {
            path : '/usercenter/homework',
            name : 'userCenter-homework',
            component: () => import('/@/pages/userCenter/homework.vue'), // 作业列表
            //meta:{name:'homework'},
          },
          {
            path : '/usercenter/homeworkdetail',
            name : 'userCenter-homeworkDetail',
            component: () => import('/@/pages/userCenter/homeworkDetail.vue'), // 指定课程作业详情
            //meta:{name:'homework'},
          },
          {
            path : '/order/userorders',
            name : 'order-userOrders',
            component: () => import('/@/pages/order/userOrders.vue'), // 订单列表
            //meta:{name:'homework'},
          },
          {
            path : '/qa/userqa',
            name : 'qa-userqa',
            component: () => import('/@/pages/qa/userqa.vue'), // 答疑
            //meta:{name:'homework'},
          },
          {
            path : '/exam/userExam',
            name : 'exam-userExam',
            component: () => import('/@/pages/exam/userExam.vue'), // 考试
            //meta:{name:'homework'},
          },
        ]
      }

    ]
  }
)

// routes.push({
//   path: '/',
//   name: 'index',
//   redirect: '/homepage',
//   //component: () => import('/@/pages/homePage/index.vue'),
//   component: () => import('/@/pages/index.vue'),
//   children:[
//     {
//       path:'/usercenter',
//       name:'userCenter',
//       redirect: '/usercenter/usercenter',
//       component: () =>import('/@/pages/userCenter/index.vue'), // 学生首页
//       children:[
//         {
//           path : '/usercenter/usercenter',
//           name : 'userCenter-userCenter',
//           component: () => import('/@/pages/userCenter/userCenter.vue'), // 学生首页
//           meta:{name:'userCenter'},
//         },
//       ]
//     }
//   ]
// })

//导入生成的路由数据
const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

export default router
